/*package com.wsjc.common.core.utils;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.platform.entity.AtpBaseData;
import com.platform.entity.Atp_test;
import com.platform.entity.Bd_test;
import com.platform.entity.Disinfected;
import com.platform.entity.Sterilization;
import com.platform.entity.Sterilization_device;
import com.platform.entity.Uv_test;

public class ParseData {

	private static Log log = LogFactory.getLog("accessRecordLog");
	
	private static int point = 0;

	public static void main(String[] args) throws IOException {

		*//************* 测试 **************//*
		// String path = "G:2016-9-30 10-51-21 S0001.dtb" ;
//		String path = "2016-09-30 12-21-45  S0001.dtb";
//		String sterilization_device_path = "L2016-12-28 11-08-43  S0002.dtb";
//		String disinfected_path = "2016-10-11 11-34-12  X0001.dtb";
//		String atp_path = "ATP2016-10-14 14-51-16  供应室.dtb";
		
		String UVPath = "F:2017-09-06 11-09-56  1857(171201).dtb";
//		String UVPath = "F:2017-11-14 09-39-02  1.dtb";
		
		InputStream is = new FileInputStream(UVPath);
		analysis(is);
		// DataProcessing(path) ;
	}

	public static String getValueToByte(byte[] data) throws IOException {

		int number = 0; // 获取 数据的字节长度
		int i = point;

		for (; i <= point + 3; i++) {
			number = number * 256 + data[i];
		}

		point = point + 4;
		String value = "";
		int y = 0;
		byte[] Data = new byte[2];

//		System.out.println("getValueToByte() 方法point + 4 的  值 ：" + point);

		while (y < number) {

			if (data[point + y] < 0) {
				Data[0] = data[point + y];
				Data[1] = data[point + 1 + y];
				// Data[2] = 0 ;
				value = value + bytesToString(Data);
				y = y + 2;
			} else {
				value = value + (char) data[point + y];
				y = y + 1;
			}
		}

		point = point + number;

		System.out.println("getValueToByte() 方法执行完 ---》 point 值 ：" + point);

		return value;

	}

	*//******** byte 转 int *******//*
	public static int bytesToInt2(byte[] src, int offset) {
		int value;
		value = (int) (((src[offset] & 0xFF) << 24) | ((src[offset + 1] & 0xFF) << 16) | ((src[offset + 2] & 0xFF) << 8)
				| (src[offset + 3] & 0xFF));
		return value;
	}

	*//************ byte 转 String ****************//*
	public static String bytesToString(byte[] src) {
		String value = "";
		try {
			value = new String(src, "GBK");
		} catch (UnsupportedEncodingException e) {
			System.out.println("出现异常了---------------------------------");
			e.printStackTrace();
		}
		return value;
	}

	*//*************************************************************
	 * 甲方 给提供的 解析数据算法
	 *******************************************************//*

	public static Map<String, Object> analysis(InputStream inStream ) throws IOException {

		Map<String, Object> map = new HashMap<String, Object>();

//		InputStream is = new FileInputStream(filepath);
		BufferedInputStream bufin = new BufferedInputStream(inStream);
		
		DataInputStream datain = new DataInputStream(bufin);
		int dataNum = datain.readInt();
		Byte typeData = datain.readByte();

		switch (typeData.intValue()) {
		case 11: // 解析灭菌效果包
			log.info("数据包类型" + typeData.intValue() + " 灭菌效果包");
//			System.out.println("数据包类型" + typeData.intValue() + " 灭菌效果包");
			Sterilization mj11 = analysisSterilization11(datain);
			log.info("数据包内容mj11  ：" + mj11.toString());
//			System.out.println("数据包内容mj11  ：" + mj11.toString());
			map.put("type", "mj");
			map.put("mj", mj11);
			break;
		case 1: // 解析灭菌效果包
			log.info("数据包类型" + typeData.intValue() + " 灭菌效果包");
//			System.out.println("数据包类型" + typeData.intValue() + " 灭菌效果包");
			Sterilization mj = analysisSterilization(datain);
			log.info("数据包内容  ：" + mj.toString());
//			System.out.println("数据包内容  ：" + mj.toString());
			map.put("type", "mj");
			map.put("mj", mj);
			break;
		case 2: // 解析灭菌设备包
			log.info("数据包类型" + typeData.intValue() + " 灭菌设备包");
//			System.out.println("数据包类型" + typeData.intValue() + " 灭菌设备包");
			Sterilization_device mjsb = analysisSterilizationDevice(datain);
			log.info("数据包内容" + mjsb.toString());
//			System.out.println("数据包内容" + mjsb.toString());
			map.put("type", "mjsb");
			map.put("mjsb", mjsb);
			break;
		case 3: // 解析消毒效果包
			log.info("数据包类型" + typeData.intValue() + " 灭菌设备包");
//			System.out.println("数据包类型" + typeData.intValue() + " 灭菌设备包");
			Disinfected xd = analysisDisinfected(datain);
			log.info("数据包内容" + xd.toString());
//			System.out.println("数据包内容" + xd.toString());
			map.put("type", "xd");
			map.put("xd", xd);
			break;
		case 4: // 解析BD测试包
			log.info("数据包类型" + typeData.intValue() + " BD测试包");
//			System.out.println("数据包类型" + typeData.intValue() + " BD测试包");
			Bd_test bd = analysisBd_test(datain);
			log.info("数据包内容" + bd.toString());
//			System.out.println("数据包内容" + bd.toString());
			map.put("type", "bd");
			map.put("bd", bd);
			break;
		case 5: // 解析ATP测试包
			log.info("数据包类型" + typeData.intValue() + " 灭菌设备包");
//			System.out.println("数据包类型" + typeData.intValue() + " 灭菌设备包");
			Atp_test atp = analysisATP(datain);
			log.info("数据包内容" + atp.toString());
//			System.out.println("数据包内容" + atp.toString());
			map.put("type", "atp");
			map.put("atp", atp);
			break;
		case 6:// 解析紫外测试包
			log.info("数据包类型" + typeData.intValue() + " 灭菌设备包");
			System.out.println("数据包类型" + typeData.intValue() + " 灭菌设备包");
			Uv_test uv = analysisUv_test(datain);
			log.info("数据包内容" + uv.toString());
//			System.out.println("数据包内容" + uv.toString());
			map.put("type", "uv");
			map.put("uv", uv);
			break;
		default:
			break;
		}

		datain.close();
		bufin.close();
		inStream.close();

		return map;
	}

	*//**
	 * 高字节数组转换为float
	 * 
	 * @param b
	 *            byte[]
	 * @return float
	 *//*
	public static float hBytesToFloat(byte[] b) {
		int i = 0;
		Float F = new Float(0.0);
		i = ((((b[0] & 0xff) << 8 | (b[1] & 0xff)) << 8) | (b[2] & 0xff)) << 8 | (b[3] & 0xff);
		return F.intBitsToFloat(i);
	}

	*//**
	 * 低字节数组转换为float
	 * 
	 * @param b
	 *            byte[]
	 * @return float
	 *//*
	public static float lBytesToFloat(byte[] b) {
		int i = 0;
		Float F = new Float(0.000);
		i = ((((b[3] & 0xff) << 8 | (b[2] & 0xff)) << 8) | (b[1] & 0xff)) << 8 | (b[0] & 0xff);
		return F.intBitsToFloat(i);
	}

	public static String readStringFromData(DataInputStream datain) throws IOException {
		String str = null;
		int dataNumx = datain.readInt(); // 读取字符串字节数
		if (dataNumx > 0) {
			byte[] buf_1x = new byte[dataNumx];
			datain.read(buf_1x, 0, dataNumx);
			str = new String(buf_1x, "GBK");
		}
//		System.out.println("数据 ：" + str );
		return str;
	}

	public static Float readFloatFromData(DataInputStream datain) throws IOException {

		byte[] buf = new byte[4];
		datain.read(buf, 0, 4);
		Float max_tep = lBytesToFloat(buf);
		return max_tep;
	}

	public static String changeFloatToString3(Float a) {

		DecimalFormat decimalFormat = new DecimalFormat("0.000");// 构造方法的字符格式这里如果小数不足2位,会以0补足.
		String p = decimalFormat.format(a);// format 返回的是字符串
		return p;
	}

	public static String changeFloatToString2(Float a) {

		DecimalFormat decimalFormat = new DecimalFormat("0.00");// 构造方法的字符格式这里如果小数不足2位,会以0补足.
		String p = decimalFormat.format(a);// format 返回的是字符串
		return p;
	}

	public static String changeFloatToString1(Float a) {

		DecimalFormat decimalFormat = new DecimalFormat("0.0");// 构造方法的字符格式这里如果小数不足2位,会以0补足.
		String p = decimalFormat.format(a);// format 返回的是字符串
		return p;
	}

	public static String changeFloatToString0(Float a) {

		DecimalFormat decimalFormat = new DecimalFormat("0");// 构造方法的字符格式这里如果小数不足2位,会以0补足.
		String p = decimalFormat.format(a);// format 返回的是字符串
		return p;
	}

	public static String changeIntToString00(Byte a) {
		Format f1 = new DecimalFormat("00");
		return f1.format(a);
	}

	public static String changeIntToString000(Byte a) {
		int ing = a & 0xff;
		Format f1 = new DecimalFormat("000");
		return f1.format(ing);
	}

	*//**
	 * 解析灭菌效果包
	 * 
	 * 说明 ： 旧版本，标识位是   1 
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Sterilization
	 * @throws IOException
	 *//*
	public static Sterilization analysisSterilization(DataInputStream datain) throws IOException {

		try {
			Sterilization mj = new Sterilization();

			String str_buf = readStringFromData(datain); // 读取单位ID
			mj.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			mj.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			mj.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			mj.setDevice_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			mj.setDevice_capacity(str_buf);
			
			str_buf = readStringFromData(datain); // 使用科室
			mj.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			mj.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 设备程序号
			mj.setDevice_program_number(str_buf);

			str_buf = readStringFromData(datain); // 设备设定温度
			mj.setDevice_set_cool(str_buf);

			str_buf = readStringFromData(datain); // 设备设定时间
			mj.setDevice_set_time(str_buf);

			// /////////////////////////////////////////////
			int dataNum = datain.readInt(); // 灭菌保持时间
			Integer keep_time = datain.readInt();
			mj.setKeeptime(keep_time.toString());

			dataNum = datain.readInt(); // 温度最高值
			mj.setCool_max_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力真空度
			mj.setPressure_vacuum_degree(changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力范围

			mj.setPressure_range(changeFloatToString1(readFloatFromData(datain)) + " ~ "
					+ changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力反求温度
			mj.setPressure_reverse_cool(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 灭菌效果判定
			*//**
			 * 由于此项为一个字段 ，但是有五个判定，都合并到此字段，“；”为分割符
			 *//*
			byte[] judge = new byte[6];
			datain.read(judge, 0, 6);
		
			String smsInfo = "" ; // 短信推送，具体不合格项，可能是  时间不合格 和 温度不合格。都不合格就拼接起来。
			String str_judge = "";
			// 第一项 是时间 合格/不合格， 第二次循环是判断  温度 合格/不合格。 
			for (int i = 0; i < judge.length - 1; i++) {
				if (0x00 == judge[i]) {
					str_judge = str_judge + "不合格;";
					if(i == 0){
						smsInfo = smsInfo+"‘时间不合格’ " ;					
					}else if(i == 1){
						smsInfo = smsInfo+"‘温度不合格’ " ;	
					}
				} else if (0x01 == judge[i]) {
					str_judge = str_judge + "合格;";
				} else {
					str_judge = str_judge + "-;";
				}
			}
			mj.setJudged(str_judge);

			// 检测结果
			if (0x00 == judge[5]) {
				mj.setTest_result("不合格");
				mj.setSmsInfo(smsInfo);
			} else if (0x01 == judge[5]) {
				mj.setTest_result("合格");
			}

			dataNum = datain.readInt(); // 设备保持时间
			keep_time = datain.readInt();
			mj.setDevice_keeptime(keep_time.toString());

			dataNum = datain.readInt(); // 温度波动性
			mj.setCool_volatility(changeFloatToString3(readFloatFromData(datain)));

			/////////////////////////////////////////////

			*//**
			 * 此字段为新加，原类中没有
			 *//*
			str_buf = readStringFromData(datain);
			mj.setRecorder_id(str_buf);

			dataNum = datain.readInt(); // 测试开始时间

			Byte year = datain.readByte();
			Byte month = datain.readByte();
			Byte day = datain.readByte();
			Byte hour = datain.readByte();
			Byte min = datain.readByte();
			Byte sec = datain.readByte();
			String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
					+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min) + ":"
					+ changeIntToString00(sec);
			mj.setTest_time(DateUtil.fomatDatetime(test_time));

			dataNum = datain.readInt(); // 间隔时间
			int keep_time_i = datain.readInt();

			dataNum = datain.readInt(); // 记录仪类型
			int recorder_type = -1;
			Byte keep_time_1 = datain.readByte();
			recorder_type = keep_time_1.intValue();

			byte[] buf = null;
			dataNum = datain.readInt(); // 原始数据数量
			if (dataNum > 0) {

				switch (recorder_type) {
				case 1:// 单温
				{
					buf = new byte[4 * dataNum];
					datain.read(buf, 0, 4 * dataNum);
				}
					break;
				case 2:// 温压
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				case 3: // 双温
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				default:
					break;
				}

			}

			str_buf = readStringFromData(datain); // 灭菌包信息
			mj.setData_package_name(str_buf);

			str_buf = readStringFromData(datain);// 摄像索引
			mj.setCamera_index(str_buf);
			// System.out.println( mj.toString());
			return mj;
		} catch (Exception e) {
			throw new IOException();
		}

	}
	
	
	*//**
	 * 解析灭菌效果包
	 * 
	 * 说明 ： 新版本，标识位是   11
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Sterilization
	 * @throws IOException
	 *//*
	public static Sterilization analysisSterilization11(DataInputStream datain) throws IOException {

		try {
			Sterilization mj = new Sterilization();

			String str_buf = readStringFromData(datain); // 读取单位ID
			mj.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			mj.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			mj.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			mj.setDevice_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			mj.setDevice_capacity(str_buf);
			
			str_buf = readStringFromData(datain); // 设备级别
			mj.setDevice_level(str_buf);
			str_buf = readStringFromData(datain); // 设备类型
			mj.setDevice_type(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			mj.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			mj.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 设备程序号
			mj.setDevice_program_number(str_buf);

			str_buf = readStringFromData(datain); // 设备设定温度
			mj.setDevice_set_cool(str_buf);

			str_buf = readStringFromData(datain); // 设备设定时间
			mj.setDevice_set_time(str_buf);

			// /////////////////////////////////////////////
			int dataNum = datain.readInt(); // 灭菌保持时间
			Integer keep_time = datain.readInt();
			mj.setKeeptime(keep_time.toString());

			dataNum = datain.readInt(); // 温度最高值
			mj.setCool_max_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力真空度
			mj.setPressure_vacuum_degree(changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力范围

			mj.setPressure_range(changeFloatToString1(readFloatFromData(datain)) + " ~ "
					+ changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力反求温度
			mj.setPressure_reverse_cool(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 灭菌效果判定
			*//**
			 * 由于此项为一个字段 ，但是有五个判定，都合并到此字段，“；”为分割符
			 *//*
			byte[] judge = new byte[6];
			datain.read(judge, 0, 6);

			String smsInfo = "" ; // 短信推送，具体不合格项，可能是  时间不合格 和 温度不合格。都不合格就拼接起来。
			String str_judge = "";
			int count = 0 ;  // 循环次数， 第二项（循环第二次）判断 2 3 
			for (int i = 0; i < judge.length - 1; i++) {
				
				//第二项判断 2 3
				if(count == 1 ){
					if (0x00 == judge[i]) {
						str_judge = str_judge + "不合格;";
						 smsInfo = smsInfo+"‘温度不合格’ " ;					
					} else if (0x01 == judge[i]) {
						str_judge = str_judge + "合格;";
					} else if (0x02 == judge[i]) {
						str_judge = str_judge + "灭菌温度低于设定温度;";
						smsInfo = smsInfo+"‘灭菌温度低于设定温度’ " ;	
					} else if (0x03 == judge[i]) {
						str_judge = str_judge + "灭菌温度超出设定温度;";
						smsInfo = smsInfo+"‘灭菌温度超出设定温度’ " ;	
					}else {
						str_judge = str_judge + "-;";
					}
					count++ ;
					continue ;
				}
				
				if (0x00 == judge[i]) {
					str_judge = str_judge + "不合格;";
					if(count == 0 ){
						smsInfo = smsInfo+"‘时间不合格’ " ;
					}
				} else if (0x01 == judge[i]) {
					str_judge = str_judge + "合格;";
				} else {
					str_judge = str_judge + "-;";
				}
				count++ ;
			}
			mj.setJudged(str_judge);

			// 检测结果
			if (0x00 == judge[5]) {
				mj.setTest_result("不合格");
				mj.setSmsInfo(smsInfo);
			} else if (0x01 == judge[5]) {
				mj.setTest_result("合格");
			}

			dataNum = datain.readInt(); // 设备保持时间
			keep_time = datain.readInt();
			mj.setDevice_keeptime(keep_time.toString());

			dataNum = datain.readInt(); // 温度波动性
			mj.setCool_volatility(changeFloatToString3(readFloatFromData(datain)));

			/////////////////////////////////////////////

			*//**
			 * 此字段为新加，原类中没有
			 *//*
			str_buf = readStringFromData(datain);
			mj.setRecorder_id(str_buf);

			dataNum = datain.readInt(); // 测试开始时间

			Byte year = datain.readByte();
			Byte month = datain.readByte();
			Byte day = datain.readByte();
			Byte hour = datain.readByte();
			Byte min = datain.readByte();
			Byte sec = datain.readByte();
			String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
					+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min) + ":"
					+ changeIntToString00(sec);
			mj.setTest_time(DateUtil.fomatDatetime(test_time));

			dataNum = datain.readInt(); // 间隔时间
			int keep_time_i = datain.readInt();

			dataNum = datain.readInt(); // 记录仪类型
			int recorder_type = -1;
			Byte keep_time_1 = datain.readByte();
			recorder_type = keep_time_1.intValue();

			byte[] buf = null;
			dataNum = datain.readInt(); // 原始数据数量
			if (dataNum > 0) {

				switch (recorder_type) {
				case 1:// 单温
				{
					buf = new byte[4 * dataNum];
					datain.read(buf, 0, 4 * dataNum);
				}
					break;
				case 2:// 温压
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				case 3: // 双温
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				default:
					break;
				}

			}

			str_buf = readStringFromData(datain); // 灭菌包信息
			mj.setData_package_name(str_buf);

			str_buf = readStringFromData(datain);// 摄像索引
			mj.setCamera_index(str_buf);
			// System.out.println( mj.toString());
			return mj;
		} catch (Exception e) {
			throw new IOException();
		}

	}
	
	

	*//**
	 * 解析灭菌设备包
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Sterilization_device
	 * @throws IOException
	 *//*
	public static Sterilization_device analysisSterilizationDevice(DataInputStream datain) throws IOException {

		try {

			Sterilization_device mjsb = new Sterilization_device();

			String str_buf = readStringFromData(datain); // 读取单位ID
			mjsb.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			mjsb.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			mjsb.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			mjsb.setDevice_kinds(str_buf);
			
			str_buf = readStringFromData(datain); // 设备容量
			mjsb.setDevice_capacity(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			mjsb.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			mjsb.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 设备程序号
			mjsb.setDevice_program_number(str_buf);

			str_buf = readStringFromData(datain); // 设备设定温度
			mjsb.setDevice_set_cool(str_buf);

			str_buf = readStringFromData(datain); // 设备设定时间
			mjsb.setDevice_set_time(str_buf);

			//////////////////// Data result///////////////////////////
			int dataNum = datain.readInt(); // 平衡时间
			Integer balance_time = datain.readInt();
			mjsb.setBalance_time(balance_time.toString());

			dataNum = datain.readInt(); // 温度最高值
			mjsb.setCool_max_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 温度最低值
			mjsb.setCool_min_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 设备保持时间
			Integer device_keeptime = datain.readInt();
			mjsb.setDevice_keeptime(device_keeptime.toString());

			dataNum = datain.readInt(); // 任意两点波动性
			mjsb.setTwopoint_volatility(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力真空度
			mjsb.setPressure_vacuum_degree(changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力范围
			mjsb.setPressure_range(changeFloatToString1(readFloatFromData(datain)) + " ~ "
					+ changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力反求温度
			mjsb.setPressure_reverse_cool(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 灭菌设备判定
			*//**
			 * 由于此项为一个字段 ，但是有五个判定，都合并到此字段，“；”为分割符
			 *//*
			byte[] judge = new byte[9];
			datain.read(judge, 0, 9);

			String str_judge = "";
			for (int i = 0; i < 8; i++) {
				if (0x00 == judge[i]) {
					str_judge = str_judge + "不合格；";
				} else if (0x01 == judge[i]) {
					str_judge = str_judge + "合格；";
				} else {
					str_judge = str_judge + "-；";
				}
			}
			mjsb.setJudged(str_judge);

			// 检测结果
			if (0x00 == judge[8]) {
				mjsb.setTest_result("不合格");
			} else if (0x01 == judge[8]) {
				mjsb.setTest_result("合格");
			}

			////////////////////// Data source/////////////////////////////////
			dataNum = datain.readInt(); // 记录仪数量
			Integer recorder_num = datain.readInt();

			for (int i = 0; i < recorder_num; i++) {

				dataNum = datain.readInt(); // 位置
				Byte location = datain.readByte();

				str_buf = readStringFromData(datain); // 记录仪编号

				dataNum = datain.readInt(); // 测试开始时间
				Byte year = datain.readByte();
				Byte month = datain.readByte();
				Byte day = datain.readByte();
				Byte hour = datain.readByte();
				Byte min = datain.readByte();
				Byte sec = datain.readByte();
				if (0 == i) {
					String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
							+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":"
							+ changeIntToString00(min) + ":" + changeIntToString00(sec);

					mjsb.setTest_time(DateUtil.fomatDatetime(test_time));

				}

				dataNum = datain.readInt(); // 间隔时间
				Integer buf_i = datain.readInt();

				dataNum = datain.readInt(); // 记录仪类型
				int recorder_type = -1;
				Byte keep_time_1 = datain.readByte();
				recorder_type = keep_time_1.intValue();

				dataNum = datain.readInt(); // 单点保持时间
				buf_i = datain.readInt();

				dataNum = datain.readInt(); // 温度最高值
				Float f_buf = readFloatFromData(datain);

				dataNum = datain.readInt(); // 温度最低值
				f_buf = readFloatFromData(datain);

				dataNum = datain.readInt(); // 单点波动性
				f_buf = readFloatFromData(datain);

				dataNum = datain.readInt(); // 压力真空度
				f_buf = readFloatFromData(datain);

				dataNum = datain.readInt(); // 压力范围
				f_buf = readFloatFromData(datain);
				f_buf = readFloatFromData(datain);
				// System.out.println(f_buf+" ~ "+f_buf);
				dataNum = datain.readInt(); // 压力反求温度
				f_buf = readFloatFromData(datain);

				byte[] buf = null;
				dataNum = datain.readInt(); // 原始数据数量
				// System.out.println("原始数据数量"+dataNum);
				if (dataNum > 0) {
					switch (recorder_type) {
					case 1:// 单温
					{
						buf = new byte[4 * dataNum];
						datain.read(buf, 0, 4 * dataNum);
					}
						break;
					case 2:// 温压
					{
						buf = new byte[8 * dataNum];
						datain.read(buf, 0, 8 * dataNum);
					}
						break;
					case 3: // 双温
					{
						buf = new byte[8 * dataNum];
						datain.read(buf, 0, 8 * dataNum);
					}
						break;
					}
				}
			}

			str_buf = readStringFromData(datain);// 摄像索引
			mjsb.setCamera_index(str_buf);

			// try
			// {
			// datain.readChar();
			// }
			// catch(EOFException e){
			// System.out.println( "读取完成");
			// }
			return mjsb;
		} catch (Exception e) {
			throw new IOException();
		}

	}

	*//**
	 * 解析消毒效果包
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Disinfected
	 * @throws IOException
	 *//*
	public static Disinfected analysisDisinfected(DataInputStream datain) throws IOException {

		try {

			Disinfected xd = new Disinfected();

			String str_buf = readStringFromData(datain); // 单位ID
			xd.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			xd.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			xd.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			xd.setDevice_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			xd.setDevice_capacity(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			xd.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			xd.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 设备程序号
			xd.setDevice_program_number(str_buf);

			str_buf = readStringFromData(datain); // 设备设定温度
			xd.setDevice_set_cool(str_buf);

			str_buf = readStringFromData(datain); // 设备设定时间
			xd.setDevice_set_time(str_buf);

			str_buf = readStringFromData(datain); // 理论A0值
			xd.setTheory_ao_value(str_buf);

			// // ////////////////////Data result/////////////////////////
			int dataNum = datain.readInt(); // 保持时间
			Integer keep_time = datain.readInt();
			xd.setKeeptime(keep_time.toString());

			dataNum = datain.readInt(); // 实测A0值
			xd.setTest_ao_value(changeFloatToString0(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力范围
			xd.setPressure_range(changeFloatToString1(readFloatFromData(datain)) + " ~ "
					+ changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 消毒效果判定
			// System.out.println("num"+dataNum);
			*//**
			 * 由于此项为一个字段 ，但是有五个判定，都合并到此字段，“；”为分割符
			 *//*
			byte[] judge = new byte[4];
			datain.read(judge, 0, 4);

			String str_judge = "";
			for (int i = 0; i < 3; i++) {
				if (0x00 == judge[i]) {
					str_judge = str_judge + "不合格；";
				} else if (0x01 == judge[i]) {
					str_judge = str_judge + "合格；";
				} else {
					str_judge = str_judge + "-；";
				}
			}
			xd.setJudged(str_judge);

			// 检测结果
			if (0x00 == judge[3]) {
				xd.setTest_result("不合格");
			} else if (0x01 == judge[3]) {
				xd.setTest_result("合格");
			}

			/////////////// Data source///////////////////////
			*//**
			 * 此字段为新加，原类中没有
			 *//*
			str_buf = readStringFromData(datain); // 温度记录仪编号
			xd.setRecorder_id(str_buf);

			dataNum = datain.readInt(); // 测试开始时间
			Byte year = datain.readByte();
			Byte month = datain.readByte();
			Byte day = datain.readByte();
			Byte hour = datain.readByte();
			Byte min = datain.readByte();
			Byte sec = datain.readByte();

			String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
					+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min) + ":"
					+ changeIntToString00(sec);

			xd.setTest_time(DateUtil.fomatDatetime(test_time));

			dataNum = datain.readInt(); // 间隔时间
			int keep_time_i = datain.readInt();

			dataNum = datain.readInt(); // 记录仪类型
			int recorder_type = -1;
			Byte keep_time_1 = datain.readByte();
			recorder_type = keep_time_1.intValue();

			byte[] buf = null;
			dataNum = datain.readInt(); // 原始数据数量
			if (dataNum > 0) {

				switch (recorder_type) {
				case 1:// 单温
				{
					buf = new byte[4 * dataNum];
					datain.read(buf, 0, 4 * dataNum);
				}
					break;
				case 2:// 温压
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				case 3: // 双温
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				}
			}
			str_buf = readStringFromData(datain);// 摄像索引
			xd.setCamera_index(str_buf);

			// try
			// {
			// datain.readChar();
			// }
			// catch(EOFException e){
			// System.out.println( "读取完成");
			// }
			return xd;
		} catch (Exception e) {
			throw new IOException();
		}
	}

	*//**
	 * 解析ATP检测包
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Atp_test
	 * @throws IOException
	 *//*
	public static Atp_test analysisATP(DataInputStream datain) throws IOException {

		try {

			Atp_test atp = new Atp_test();

			String str_buf = readStringFromData(datain); // 读取单位ID
			atp.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			atp.setAtp_device_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			atp.setAtp_device_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			atp.setAtp_device_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			atp.setAtp_device_capacity(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			atp.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			atp.setUse_persion(str_buf);

			////////////////// Data source/////////////////////////////
			*//**
			 * 此字段为新加，原类中没有
			 *//*
			str_buf = readStringFromData(datain); // 检测仪编号
			// System.out.println(str_buf);

			Integer data_no = datain.readInt(); // 数据量
			// System.out.println("数据量"+data_no);
			AtpBaseData atp_base_data = null;
			atp.test_messages.clear();
			int dataNum = 0;
			for (int i = 0; i < data_no; i++) {
				atp_base_data = new AtpBaseData();

				str_buf = readStringFromData(datain); // 名称
				atp_base_data.setPoint_name(str_buf);

				str_buf = readStringFromData(datain); // 检测点描述
				atp_base_data.setTest_point_info(str_buf);

				dataNum = datain.readInt(); // 判定限1
				Integer num1 = datain.readInt();
				atp_base_data.setItms_up(num1.toString());

				dataNum = datain.readInt(); // 判定限2
				num1 = datain.readInt();
				atp_base_data.setItms_down(num1.toString());

				dataNum = datain.readInt(); // 检测值
				num1 = datain.readInt();
				atp_base_data.setTest_value(num1.toString());

				dataNum = datain.readInt(); // 单位
				Byte unit = datain.readByte();
				switch (unit.intValue()) {
				case 1:
					atp_base_data.setPart("RLU");
					break;
				case 2:
					atp_base_data.setPart("Amol");
					break;
				}

				Date date = new Date();
				dataNum = datain.readInt(); // 测试开始时间
				Byte year = datain.readByte();
				Byte month = datain.readByte();
				Byte day = datain.readByte();
				Byte hour = datain.readByte();
				Byte min = datain.readByte();
				Byte sec = datain.readByte();

				String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
						+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min)
						+ ":" + changeIntToString00(sec);
				atp_base_data.setTest_time(DateUtil.fomatDatetime(test_time));

				dataNum = datain.readInt(); // 结果
				Byte result = datain.readByte();

				switch (result.intValue()) {
				case 1:
					atp_base_data.setTest_result("合格");
					break;
				case 2:
					atp_base_data.setTest_result("临界");
					break;
				case 3:
					atp_base_data.setTest_result("不合格");
					break;
				case 4:
					atp_base_data.setTest_result("无法判定");
					break;
				}
				atp.test_messages.add(atp_base_data);

			}

			str_buf = readStringFromData(datain);// 摄像索引
			atp.setCamera_index(str_buf);
			// try
			// {
			// datain.readChar();
			// }
			// catch(EOFException e){
			// System.out.println( "读取完成");
			// }
			//
			// for (AtpBaseData iterable_element : atp.test_messages) {
			// System.out.print( iterable_element.getPoint_name() +"
			// "+iterable_element.getTest_point_info()+"
			// "+iterable_element.getItms_up()+
			// " "+iterable_element.getItms_down()+"
			// "+iterable_element.getTest_value()+
			// " "+ iterable_element.getPart()+"
			// "+iterable_element.getTest_time()+" "+
			// iterable_element.getTesting_result()+"\n");
			// }
			return atp;
		} catch (Exception e) {
			throw new IOException();
		}
	}

	*//**
	 * 解析BD测试数据
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Sterilization
	 * @throws IOException
	 *//*
	public static Bd_test analysisBd_test(DataInputStream datain) throws IOException {

		try {

			Bd_test bd = new Bd_test();

			String str_buf = readStringFromData(datain); // 读取单位ID
			bd.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			bd.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			bd.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			bd.setDevice_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			bd.setDevice_capacity(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			bd.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			bd.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 设备程序号
			bd.setDevice_program_number(str_buf);

			str_buf = readStringFromData(datain); // 设备设定温度
			bd.setDevice_set_cool(str_buf);

			str_buf = readStringFromData(datain); // 设备设定时间
			bd.setDevice_set_time(str_buf);

			///////////////// Data result////////////////////////////
			int dataNum = datain.readInt(); // 平衡时间
			Integer int_temp = datain.readInt();
			bd.setBalance_time(int_temp.toString());

			dataNum = datain.readInt(); // 温度最高值
			bd.setCool_max_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 点1温度值
			bd.setPoint1_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 点2温度值
			bd.setPoint2_value(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 设备保持时间
			int_temp = datain.readInt();
			bd.setDevice_keeptime(int_temp.toString());

			dataNum = datain.readInt(); // 两点波动性
			bd.setTwopoint_volatility(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力真空度
			bd.setPressure_vacuum_degree(changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力范围
			bd.setPressure_range(changeFloatToString1(readFloatFromData(datain)) + " ~ "
					+ changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 压力反求温度
			bd.setPressure_reverse_cool(changeFloatToString3(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 灭菌效果判定
			*//**
			 * 由于此项为一个字段 ，但是有五个判定，都合并到此字段，“；”为分割符
			 *//*
			byte[] judge = new byte[10];
			datain.read(judge, 0, 10);

			String str_judge = "";
			for (int i = 0; i < 9; i++) {
				if (0x00 == judge[i]) {
					str_judge = str_judge + "不合格；";
				} else if (0x01 == judge[i]) {
					str_judge = str_judge + "合格；";
				} else {
					str_judge = str_judge + "-；";
				}
			}
			bd.setJudged(str_judge);

			// 检测结果
			if (0x00 == judge[9]) {
				bd.setTest_result("不合格");
			} else if (0x01 == judge[9]) {
				bd.setTest_result("合格");
			}

			////////////////// Data source//////////////////
			*//**
			 * 此字段为新加，原类中没有
			 *//*
			str_buf = readStringFromData(datain); // 记录仪编号
			bd.setRecorder_id(str_buf);

			dataNum = datain.readInt(); // 测试开始时间
			Byte year = datain.readByte();
			Byte month = datain.readByte();
			Byte day = datain.readByte();
			Byte hour = datain.readByte();
			Byte min = datain.readByte();
			Byte sec = datain.readByte();

			String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
					+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min) + ":"
					+ changeIntToString00(sec);
			bd.setTest_time(DateUtil.fomatDatetime(test_time));

			dataNum = datain.readInt(); // 间隔时间
			dataNum = datain.readInt();

			dataNum = datain.readInt(); // 记录仪类型
			int recorder_type = -1;
			Byte keep_time_1 = datain.readByte();
			recorder_type = keep_time_1.intValue();

			dataNum = datain.readInt(); // 单点保持时间
			dataNum = datain.readInt();

			dataNum = datain.readInt(); // 点1单点波动性
			Float f_temp = readFloatFromData(datain);

			dataNum = datain.readInt(); // 点2单点波动性
			f_temp = readFloatFromData(datain);

			byte[] buf = null;
			dataNum = datain.readInt(); // 两点原始数据
			if (dataNum > 0) {

				switch (recorder_type) {
				case 2:// 温度压力
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				case 3:// 双温
				{
					buf = new byte[8 * dataNum];
					datain.read(buf, 0, 8 * dataNum);
				}
					break;
				case 4: // 两温度一压力
				{
					buf = new byte[12 * dataNum];
					datain.read(buf, 0, 12 * dataNum);
				}
					break;
				}
			}

			str_buf = readStringFromData(datain);// 摄像索引
			bd.setCamera_index(str_buf);
			// try
			// {
			// datain.readChar();
			// }
			// catch(EOFException e){
			// System.out.println( "读取完成");
			// }

			return bd;
		} catch (Exception e) {
			throw new IOException();
		}
	}

	*//**
	 * 解析紫外测试包
	 * 
	 * @param DataInputStream
	 *            datain
	 * @return Uv_test
	 * @throws IOException
	 *//*
	public static Uv_test analysisUv_test(DataInputStream datain) throws IOException {

		try {
			Uv_test uv = new Uv_test();

			String str_buf = readStringFromData(datain); // 读取单位ID
			uv.setHospital_id(str_buf);

			str_buf = readStringFromData(datain); // 设备编号
			uv.setDevice_number(str_buf);

			str_buf = readStringFromData(datain); // 设备品牌
			uv.setDevice_brand(str_buf);

			str_buf = readStringFromData(datain); // 设备型号
			uv.setDevice_kinds(str_buf);

			str_buf = readStringFromData(datain); // 设备容量
			uv.setDevice_capacity(str_buf);

			str_buf = readStringFromData(datain); // 使用科室
			uv.setUse_department(str_buf);

			str_buf = readStringFromData(datain); // 操作者
			uv.setUse_persion(str_buf);

			str_buf = readStringFromData(datain); // 检测仪编号
			uv.setDetector_number(str_buf);

			str_buf = readStringFromData(datain); // 紫外灯ID
			uv.setUvlamp_id(str_buf);

			str_buf = readStringFromData(datain); // 累计使用时间
			uv.setUser_time(str_buf);
			str_buf = readStringFromData(datain); // 最近开启时间
			uv.setLast_open_time(str_buf);
			str_buf = readStringFromData(datain); // 最近关闭时间
			uv.setLast_close_time(str_buf);

			int dataNum = datain.readInt(); // 使用时间判定
			int time_judge = new Byte(datain.readByte()).intValue();
			switch (time_judge) {
			case 0:
				uv.setUse_time_judged("超出使用期");
				break;
			case 1:
				uv.setUse_time_judged("使用期内");
				break;
			case 2:
				uv.setUse_time_judged("不判定");
				break;
			}

			dataNum = datain.readInt(); // 测试开始时间
			Byte year = datain.readByte();
			Byte month = datain.readByte();
			Byte day = datain.readByte();
			Byte hour = datain.readByte();
			Byte min = datain.readByte();
			Byte sec = datain.readByte();
			// uv.setTest_time();
//			System.out.println("year"+year);
			String test_time = "20" + changeIntToString00(year) + "-" + changeIntToString00(month) + "-"
					+ changeIntToString00(day) + " " + changeIntToString00(hour) + ":" + changeIntToString00(min) + ":"
					+ changeIntToString00(sec);
			uv.setTest_time(DateUtil.fomatDatetime(test_time));
			//uv.setTest_time(test_time);
			//
			dataNum = datain.readInt(); // 光照强度
			uv.setLight_intensity(changeFloatToString2(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 检测环境温度
			uv.setTest_habitat_cool(changeFloatToString1(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 检测环境相对湿度
			uv.setTest_habitat_humidity(changeFloatToString0(readFloatFromData(datain)));

			dataNum = datain.readInt(); // 紫外照度判定
			String uvString = changeIntToString000(datain.readByte());
			// System.out.println(uvString);
			char t_judge = uvString.charAt(0);
			String result_judge = "";
			switch (Character.getNumericValue(t_judge)) {
			case 0:
				result_judge = result_judge + "温度不合格;";
				break;
			case 1:
				result_judge = result_judge + "温度合格;";
				break;
			case 2:
				result_judge = result_judge + "温度不判定;";
				break;
			}

			t_judge = uvString.charAt(1);
			switch (Character.getNumericValue(t_judge)) {
			case 0:
				result_judge = result_judge + "湿度不合格;";
				break;
			case 1:
				result_judge = result_judge + "湿度合格;";
				break;
			case 2:
				result_judge = result_judge + "湿度不判定;";
				break;
			}

			t_judge = uvString.charAt(2);
			switch (Character.getNumericValue(t_judge)) {
			case 0:
				result_judge = result_judge + "光照不合格";
				uv.setTest_result("不合格");
				break;
			case 1:
				result_judge = result_judge + "光照合格";
				uv.setTest_result("合格");
				break;
			case 2:
				result_judge = result_judge + "光照不判定";
				break;
			}

			uv.setUv_judged(result_judge);

			str_buf = readStringFromData(datain);// 摄像索引
			uv.setCamera_index(str_buf);

//			 try
//			 {
//			 datain.readChar();
//			 }
//			 catch(EOFException e){
//			 System.out.println( "读取完成123");
//			 }
			return uv;
		} catch (Exception e) {
			throw new IOException();
		}
	}

}*/